/*
 * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION!

import { int32, float32 } from "@koalaui/common"
import { KStringPtr, KBoolean, RuntimeType, runtimeType, isResource, isInstanceOf } from "@koalaui/interop"
import { NodeAttach, remember } from "@koalaui/runtime"
import { ComponentBase } from "./ComponentBase"
import { TypeChecker } from "#components"
import { ArkBaseSpanComponent } from "./ArkSpan"
import { ArkImageSpanPeer } from "./peers/ArkImageSpanPeer"
import { UseEventsProperties } from "./use_properties"
import { BaseSpan } from "./ArkSpanInterfaces"
import { ImageSpanAttribute, ImageCompleteCallback } from "./ArkImageSpanInterfaces"
import { ImageSpanAlignment, ImageFit } from "./ArkEnumsInterfaces"
import { ColorFilter } from "./ArkColorFilterMaterialized"
import { DrawingColorFilter, ImageErrorCallback } from "./ArkImageInterfaces"
import { PixelMap } from "./ArkPixelMapMaterialized"
import { ResourceStr } from "./ArkUnitsInterfaces"
/** @memo:stable */
export class ArkImageSpanComponent extends ArkBaseSpanComponent {
    getPeer(): ArkImageSpanPeer {
        return (this.peer as ArkImageSpanPeer)
    }
    /** @memo */
    public setImageSpanOptions(value: ResourceStr | PixelMap): this {
        if (this.checkPriority("setImageSpanOptions")) {
            const value_casted = value as (ResourceStr | PixelMap)
            this.getPeer()?.setImageSpanOptionsAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public verticalAlign(value: ImageSpanAlignment): this {
        if (this.checkPriority("verticalAlign")) {
            const value_casted = value as (ImageSpanAlignment)
            this.getPeer()?.verticalAlignAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public colorFilter(value: ColorFilter | DrawingColorFilter): this {
        if (this.checkPriority("colorFilter")) {
            const value_casted = value as (ColorFilter | DrawingColorFilter)
            this.getPeer()?.colorFilterAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public objectFit(value: ImageFit): this {
        if (this.checkPriority("objectFit")) {
            const value_casted = value as (ImageFit)
            this.getPeer()?.objectFitAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public onComplete(value: ImageCompleteCallback): this {
        if (this.checkPriority("onComplete")) {
            const value_casted = value as (ImageCompleteCallback)
            this.getPeer()?.onCompleteAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public onError(value: ImageErrorCallback): this {
        if (this.checkPriority("onError")) {
            const value_casted = value as (ImageErrorCallback)
            this.getPeer()?.onErrorAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public alt(value: PixelMap): this {
        if (this.checkPriority("alt")) {
            const value_casted = value as (PixelMap)
            this.getPeer()?.altAttribute(value_casted)
            return this
        }
        return this
    }
    public applyAttributesFinish(): void {
        // we calls this function outside of class, so need to make it public
        super.applyAttributesFinish()
    }
}

/** @memo */
export function ArkImageSpan(
  /** @memo */
  style: ((attributes: ArkImageSpanComponent) => void) | undefined,
  /** @memo */
  content_: (() => void) | undefined,
  value: ResourceStr | PixelMap
) {
    const receiver = remember(() => {
        return new ArkImageSpanComponent()
    })
    NodeAttach<ArkImageSpanPeer>((): ArkImageSpanPeer => ArkImageSpanPeer.create(receiver), (_: ArkImageSpanPeer) => {
        receiver.setImageSpanOptions(value)
        style?.(receiver)
        content_?.()
        receiver.applyAttributesFinish()
    })
}
